package main

import (
	"fmt"
)

func main() {

	dataString := "hello Data string"

	ch := make(chan []byte, 2)
	chOver := make(chan int)
	count := 0

	go func(ch chan []byte, data string) {

	myfor:
		for {
			select {
			case ch <- []byte(data):
				fmt.Println("cap ch:", cap(ch))
				fmt.Println("len data:", len(data))
				count += len(data)

				fmt.Println("count:", count)
			default:
				fmt.Println("满了")

				chOver <- 1

				break myfor
			}

		}

	}(ch, dataString)

	<-chOver
}
